package acs.bridge.dao;

import acs.bridge.model.bm_archive_model;
import org.springframework.jdbc.core.JdbcTemplate;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * acs.bridge.dao
 * User: KuznetsovStV
 * Date: 25.01.14
 * Time: 14:48
 */
public class bm_archive_dao_impl {
    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    private JdbcTemplate jdbcTemplate;


    public bm_archive_model selectArchive_raw(String a_table_name, BigDecimal a_raw_id) {
        bm_archive_model l_bm_archive_model = new bm_archive_model();
        List<Map> rows = this.jdbcTemplate.queryForList("select * from " + a_table_name + " where id=?", new Object[]{a_raw_id});
        for (Map row : rows) {
            l_bm_archive_model.setSrc_file_name((String) row.get("SRC_FILE_NAME"));
            l_bm_archive_model.setSrc_file_path((String) row.get("SRC_FILE_PATH"));
            l_bm_archive_model.setDst_file_name((String) row.get("DST_FILE_NAME"));
            l_bm_archive_model.setDst_file_path((String) row.get("DST_FILE_PATH"));
            l_bm_archive_model.setArchiving((BigDecimal) row.get("ARCHIVING"));
            l_bm_archive_model.setDeleting((BigDecimal) row.get("DELETING"));
        }
        return l_bm_archive_model;

    }

}
